Skip to content

Add codex backend to ccb#166

Closed
zhangzimingmmz wants to merge 2 commits intoclaude-code-best:mainfrom
zhangzimingmmz:add-codex-backend-to-ccb
Closed

Add codex backend to ccb#166
zhangzimingmmz wants to merge 2 commits intoclaude-code-best:mainfrom
zhangzimingmmz:add-codex-backend-to-ccb

Conversation

@zhangzimingmmz
Copy link
Copy Markdown

@zhangzimingmmz zhangzimingmmz commented Apr 7, 2026

Summary by CodeRabbit

  • New Features

    • Added Codex backend support as an alternative to the default Anthropic backend, selectable via CLAUDE_CODE_USE_CODEX environment variable
    • Introduced OpenSpec workflow system with four core workflows: explore, propose, apply, and archive for structured change management
  • Documentation

    • Added project setup guide (AGENTS.md) and OpenSpec workflow documentation
    • Updated README with experimental Codex backend configuration details
  • Chores

    • Refactored application branding to use configurable identity constants throughout the codebase
    • Added ccb npm script for development convenience

Let CCB run its main conversation loop against codex app-server while keeping the existing Anthropic-compatible path working. Isolate the fork branding and config so it can coexist with the official Claude Code install.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e2f70814-7bd6-48d4-8686-155c59c39154

📥 Commits

Reviewing files that changed from the base of the PR and between 70baa6f and afa6ec4.

📒 Files selected for processing (52)
  • .codex/skills/openspec-apply-change/SKILL.md
  • .codex/skills/openspec-archive-change/SKILL.md
  • .codex/skills/openspec-explore/SKILL.md
  • .codex/skills/openspec-propose/SKILL.md
  • .opencode/command/opsx-apply.md
  • .opencode/command/opsx-archive.md
  • .opencode/command/opsx-explore.md
  • .opencode/command/opsx-propose.md
  • .opencode/skills/openspec-apply-change/SKILL.md
  • .opencode/skills/openspec-archive-change/SKILL.md
  • .opencode/skills/openspec-explore/SKILL.md
  • .opencode/skills/openspec-propose/SKILL.md
  • AGENTS.md
  • README.md
  • openspec/changes/add-codex-backend-to-ccb/.openspec.yaml
  • openspec/changes/add-codex-backend-to-ccb/design.md
  • openspec/changes/add-codex-backend-to-ccb/proposal.md
  • openspec/changes/add-codex-backend-to-ccb/specs/codex-backend/spec.md
  • openspec/changes/add-codex-backend-to-ccb/tasks.md
  • openspec/config.yaml
  • package.json
  • src/components/HelpV2/HelpV2.tsx
  • src/components/LogoV2/CondensedLogo.tsx
  • src/components/LogoV2/LogoV2.tsx
  • src/components/LogoV2/WelcomeV2.tsx
  • src/entrypoints/cli.tsx
  • src/main.tsx
  • src/query/deps.ts
  • src/services/api/backend.ts
  • src/services/api/bootstrap.ts
  • src/services/api/codex.ts
  • src/services/api/metricsOptOut.ts
  • src/utils/appIdentity.ts
  • src/utils/auth.ts
  • src/utils/doctorDiagnostic.ts
  • src/utils/env.ts
  • src/utils/envUtils.ts
  • src/utils/localInstaller.ts
  • src/utils/model/__tests__/codexModels.test.ts
  • src/utils/model/__tests__/providers.test.ts
  • src/utils/model/codexModels.ts
  • src/utils/model/model.ts
  • src/utils/model/modelOptions.ts
  • src/utils/model/providers.ts
  • src/utils/model/validateModel.ts
  • src/utils/nativeInstaller/installer.ts
  • src/utils/settings/settings.ts
  • src/utils/shellConfig.ts
  • src/utils/status.tsx
  • src/utils/tmuxSocket.ts
  • src/utils/userAgent.ts
  • src/utils/worktree.ts

📝 Walkthrough

Walkthrough

This PR introduces Codex backend support for the CCB application alongside a comprehensive app identity abstraction system. The changes add OpenSpec workflow documentation for proposal/apply/archive/explore modes, implement a backend abstraction layer enabling switching between Anthropic and Codex for main conversation turns, replace hardcoded application naming with reusable constants, integrate local Codex app-server streaming via JSON-RPC, and extend model selection logic to support Codex-specific models.

Changes

Cohort / File(s) Summary
OpenSpec Workflow Documentation
.codex/skills/openspec-*/*.md, .opencode/skills/openspec-*/*.md, .opencode/command/opsx-*.md, openspec/changes/add-codex-backend-to-ccb/*
New skill definitions and command documentation for proposal/apply/archive/explore workflows, plus OpenSpec change metadata (proposal, design, spec, tasks) for adding Codex backend support.
App Identity Abstraction
src/utils/appIdentity.ts
New module exporting constants for application command name, display names, config paths, binary names, and socket/user-agent prefixes.
App Identity Constant Replacements
src/utils/doctorDiagnostic.ts, src/utils/env.ts, src/utils/envUtils.ts, src/utils/localInstaller.ts, src/utils/nativeInstaller/installer.ts, src/utils/settings/settings.ts, src/utils/shellConfig.ts, src/utils/tmuxSocket.ts, src/utils/userAgent.ts, src/utils/worktree.ts
Multiple files updated to import and use app identity constants instead of hardcoded "claude" strings for paths, binaries, config directories, and user-agent values.
UI Component Branding Updates
src/components/HelpV2/HelpV2.tsx, src/components/LogoV2/CondensedLogo.tsx, src/components/LogoV2/LogoV2.tsx, src/components/LogoV2/WelcomeV2.tsx
Components updated to use APP_DISPLAY_NAME constant instead of hardcoded "Claude Code" strings.
Backend Abstraction Layer
src/services/api/backend.ts
New module introducing MainLoopBackendTransport interface and implementations for Anthropic and Codex backends, with selection logic via getMainLoopBackendTransport().
Codex Streaming Implementation
src/services/api/codex.ts
Large new module implementing Codex streaming adapter with JSON-RPC protocol over stdio, local app-server integration, session/thread management, authentication, and event translation to CCB streaming format.
Codex Model Support
src/utils/model/codexModels.ts, src/utils/model/__tests__/codexModels.test.ts
New module for loading Codex models from local cache with fallback defaults, plus test suite validating cache parsing and visibility filtering.
Backend & Model Selection
src/utils/model/providers.ts, src/utils/model/model.ts, src/utils/model/modelOptions.ts, src/utils/model/validateModel.ts, src/utils/model/__tests__/providers.test.ts
Added getMainLoopBackend() and isCodexBackendEnabled() functions, extended model selection/validation to branch on backend type, conditional Codex model resolution and option generation.
CLI & Startup Integration
src/main.tsx, src/entrypoints/cli.tsx, src/query/deps.ts
Updated CLI version output and process naming with app identity constants, added Codex-backend-aware prefetch skipping, altered backend selection for Claude.ai MCP config fetching, redirected query dependencies to backend module.
Auth & Bootstrap Gating
src/utils/auth.ts, src/services/api/bootstrap.ts, src/utils/metricsOptOut.ts
Added early-return guards to treat Codex backend as incompatible with Claude AI OAuth, bootstrap API calls, and metrics checking; gated functions return null/false when Codex is enabled.
Diagnostic & Status
src/utils/status.tsx
Added conditional status properties showing "Main backend" and app-server URL when Codex backend is active.
Project Configuration & Docs
AGENTS.md, README.md, package.json, openspec/config.yaml
New AGENTS.md documenting project architecture, README addition describing experimental Codex backend mode, new ccb npm script, and OpenSpec project configuration file.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Main Loop
    participant Backend as Backend Layer
    participant CodexBackend as Codex Backend
    participant AuthFile as Auth File (~/.codex/auth.json)
    participant AppServer as Codex App-Server (stdio)
    participant EventStream as Event Notifications

    Client->>Backend: queryModelWithStreaming(args)
    Backend->>CodexBackend: streamTurn(args)
    
    CodexBackend->>AuthFile: Read local Codex auth
    alt Auth Missing
        CodexBackend-->>Backend: SystemAPIErrorMessage (auth error)
        Backend-->>Client: Error event
    else Auth Found
        CodexBackend->>AppServer: Spawn/connect stdio JSON-RPC
        AppServer-->>CodexBackend: Connection established
        
        CodexBackend->>AppServer: RPC thread/start
        AppServer-->>CodexBackend: Thread ID
        
        CodexBackend->>AppServer: RPC turn/start
        AppServer-->>CodexBackend: Turn started
        
        AppServer->>EventStream: Emit stream notifications
        EventStream->>CodexBackend: Receive events (filtered by thread)
        
        CodexBackend->>CodexBackend: Convert to StreamEvent/content blocks
        CodexBackend-->>Backend: Yield StreamEvent/delta events
        Backend-->>Client: Yield streaming output
        
        alt Abort Signal Received
            Client->>Backend: Abort
            Backend->>CodexBackend: Abort detected
            CodexBackend->>AppServer: RPC turn/interrupt
            AppServer-->>CodexBackend: Turn interrupted
        end
        
        CodexBackend->>CodexBackend: Finalize and cleanup
        CodexBackend-->>Backend: Yield final AssistantMessage
        Backend-->>Client: Complete
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Suggested labels

v6

Suggested reviewers

  • KonghaYao

Poem

🐰 A Codex backend blooms, JSON-RPC streams dance free,
App names dance like wildflowers—claude, ccb, identity!
Proposals flow, changes apply, archives find their rest,
The refactored rabbit declares: explore, propose, manifest!

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch add-codex-backend-to-ccb

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant